/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bluepc
 */
@Entity
@Table(name = "Dish")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Dish.findAll", query = "SELECT d FROM Dish d"),
    @NamedQuery(name = "Dish.findByIdDish", query = "SELECT d FROM Dish d WHERE d.idDish = :idDish"),
    @NamedQuery(name = "Dish.findByDishName", query = "SELECT d FROM Dish d WHERE d.dishName = :dishName"),
    @NamedQuery(name = "Dish.findByDishStatus", query = "SELECT d FROM Dish d WHERE d.dishStatus = :dishStatus"),
    @NamedQuery(name = "Dish.findByDishPrice", query = "SELECT d FROM Dish d WHERE d.dishPrice = :dishPrice"),
    @NamedQuery(name = "Dish.findByDishPicture", query = "SELECT d FROM Dish d WHERE d.dishPicture = :dishPicture")})
public class Dish implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
       @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer idDish;
    @Size(max = 250)
    @Column(name = "dish_name")
    private String dishName;
    @Column(name = "dish_status")
    private Boolean dishStatus;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "dish_price")
    private BigDecimal dishPrice;
    @Size(max = 250)
    @Column(name = "dish_picture")
    private String dishPicture;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "dish")
    private List<OrderDetails> orderDetailsList;
    @JoinColumn(name = "id_foodtype", referencedColumnName = "id_foodtype")
    @ManyToOne
    private FoodType idFoodtype;

    public Dish() {
    }

    public Dish(Integer idDish) {
        this.idDish = idDish;
    }

    public Integer getIdDish() {
        return idDish;
    }

    public void setIdDish(Integer idDish) {
        this.idDish = idDish;
    }

    public String getDishName() {
        return dishName;
    }

    public void setDishName(String dishName) {
        this.dishName = dishName;
    }

    public Boolean getDishStatus() {
        return dishStatus;
    }

    public void setDishStatus(Boolean dishStatus) {
        this.dishStatus = dishStatus;
    }

    public BigDecimal getDishPrice() {
        return dishPrice;
    }

    public void setDishPrice(BigDecimal dishPrice) {
        this.dishPrice = dishPrice;
    }

    public String getDishPicture() {
        return dishPicture;
    }

    public void setDishPicture(String dishPicture) {
        this.dishPicture = dishPicture;
    }

    @XmlTransient
    public List<OrderDetails> getOrderDetailsList() {
        return orderDetailsList;
    }

    public void setOrderDetailsList(List<OrderDetails> orderDetailsList) {
        this.orderDetailsList = orderDetailsList;
    }

    public FoodType getIdFoodtype() {
        return idFoodtype;
    }

    public void setIdFoodtype(FoodType idFoodtype) {
        this.idFoodtype = idFoodtype;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDish != null ? idDish.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Dish)) {
            return false;
        }
        Dish other = (Dish) object;
        if ((this.idDish == null && other.idDish != null) || (this.idDish != null && !this.idDish.equals(other.idDish))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Dish[ idDish=" + idDish + " ]";
    }
    
}
